package Test.D5;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 通讯协议中将时间字符转化成long并按指定格式输出
 */
public class D5Test3 {
    public static void main(String[] args) {
        
        scanTime("1666671990287");
        scanTime("1666671990287DD");
    }

    static public void scanTime(String time)
    {
        System.out.println();
    try {
            long datatime = Long.valueOf(time);
            Date date = new Date(datatime);
            SimpleDateFormat sdf = new SimpleDateFormat(
                "yyyy年MM月dd日HH时mm分"
            );
            System.out.println("显示数据:"+sdf.format(date)+" GPS数据为22.452,110.3456");
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println("传入的时间不是long 数:"+e.getMessage());
        }
        System.out.println();
    }
}
